/**
 *Copyright(c) HNA SYSTEMS Co., LTD
 *
 *@date 2013年7月25日
 * 	
 *Original Author: 郑兴(zhengxing)
 *
 *ChangeLog
 *
 */
package com.hnas.sys.web.system.validator;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import com.hnas.sys.service.system.dto.DTOResource;

/**
 * <pre>资源校验器</pre>
 * @author 郑兴(zhengxing)
 *
 */
public class ResourceValidator implements Validator {
	/*
	 * (non-Javadoc)
	 * @see org.springframework.validation.Validator#supports(java.lang.Class)
	 */
	public boolean supports(Class<?> clazz) {
		return clazz.equals(DTOResource.class);
	}

	/*
	 * (non-Javadoc)
	 * @see org.springframework.validation.Validator#validate(java.lang.Object, org.springframework.validation.Errors)
	 */
	public void validate(Object obj, Errors errors) {
		ValidationUtils.rejectIfEmpty(errors, "name", "resource.name.required","资源名称不能为空");
	}

}
